var app = getApp()
Page({
data: {
  name: '',
  weixin:'',
  
},// 标题文本框

bindNameInput: function(e) {
  this.setData({
    name: e.detail.value
  }) 
  
},// 姓名

bindWeixinInput: function(e) {
  this.setData({
    weixin: e.detail.value
  }) 
 
},//微信号

save: function(){
  if (this.data.name && this.data.weixin) {
    let tableID = 37878
    let Product = new wx.BaaS.TableObject(tableID)
    let product = Product.create()

    let Roommate = {
      name: this.data.name,
      weixin: this.data.weixin,
    }
    product.set(Roommate).save()
    wx.showModal({
      title: '插入成功！',
      content: '',
    })
    this.setData({
      name:'',
      weixin:'',
    })
  } else {
    wx.showModal({
      title: '姓名或微信号为空，请重新输入',
    })
  }
},
mate:function(e){
  wx.navigateTo({
    url: '../Roommate/Roommate',
  })
},
onShow: function () {
  wx.getStorage({
    key: 'roommate', // 初始加载无数据，故插入一条空数组的新key
    fail: function () { // 存回本地
      wx.setStorage({
        key: 'roommate',
        data: []

      })
    }
  })

}
})

